﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SMS.Entities.BaseClasses;
using System.Collections.Generic;
using SMS.Entities;
using System.Windows.Data;
using SMS.Common.Silverlight;
using System.ComponentModel;
using SMS.Controls.MenuSVC;
using SMS.Entities.Master;
using SMS.Entities.Menu;


namespace SMS.Model
{
    public class MainMasterModel
    {
        ServiceProxy<MenuServiceClient> proxy = null;
        public event Action<System.Collections.ObjectModel.ObservableCollection<Menu>> OnSelectCompleted;
        public event Action<SMSException> OnServiceError;
        public MainMasterModel()
        {
            proxy = new ServiceProxy<MenuServiceClient>("Service/MenuService.svc");
            proxy.Client.SelectMenuCompleted += new EventHandler<SelectMenuCompletedEventArgs>(Client_SelectMenuCompleted);
        }

        void Client_SelectMenuCompleted(object sender, SelectMenuCompletedEventArgs e)
        {
            if (OnSelectCompleted != null)
            {
                OnSelectCompleted(e.Result);
            }
            //throw new NotImplementedException();
        }
        public void SelectMenu(string searchText)
        {
            proxy.Client.SelectMenuAsync(App.LoggedinUserName, searchText);
        }
    }
}
